{% include "dashboard/header.html" %}
{% load filters %}
<div class="container">

    <div class="row">
        {% if success %}
            <div class="alert alert-success">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                <strong>Sucesso!</strong> Cadastro efetuado.
            </div>
        {% endif %}
        <div>
            <h3>Formulário</h3>
            <p>Tela de cadastro de informações</p>

            <div class="bs-example">
                <form class="form-horizontal" role="form" method="post" action="#">
                    {% csrf_token %}
                    <div class="panel panel-default">
                        <div class="panel-heading"><label>Nome do Formulario</label></div>
                        <div class="panel-body">
                            {% for field in form %}
                                {% if not field.name in includes %}
                                    {% include 'dashboard/field.html' with field=field %}
                                {% endif %}
                            {% endfor %}
                        </div>
                   </div>
                    {% for field in form %}
                        {% if field.name in includes %}
                           <div class="panel panel-default">
                                <div class="panel-heading">{{ field.label_tag }}</div>
                                <div class="panel-body">
                                    {% if field.value %}
                                        <input value="{{ field.value }}" type="hidden" name="{{ field.name }}"/>
                                    {% endif %}
                                    {% include includes|key:field.name|key:'template' with form=includes|key:field.name|key:'form' %}
                                </div>
                           </div>
                        {% endif %}
                    {% endfor %}
                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-5">
                          <button type="submit" class="btn btn-default">Submit</button>
                        </div>
                    </div>

                </form>
            </div>
        </div>
    </div>
</div>

{% include "dashboard/footer.html" %}